import redis

redis_cli = redis.Redis(host='47.107.87.249',port=6379,password='1234')
print(redis_cli)

if redis_cli.ping():
    # redis_cli.zadd('zset1',{
    #     'yt': 100,
    #     'lh': 123,
    #     'wam': 70,
    # })
    # items = redis_cli.zrevrange('zset1',0,9)
    # print(list(map(bytes.decode,items)))   #映射转字符串
    # print(redis_cli.zscore('zset1','yt'))
    # list1 = redis_cli.rpush('list1',1,2,3,4,5,6,56,4)
    # list2 = redis_cli.lrange('list1', 0, -1)
    # print(list(map(int, list2)))
    # print(redis_cli.lrange('list1',  0, -1))
    # bytes ---decode('utf-8')  --->str
    # str ---encode('utf-8') ---bytes
    # print(redis_cli.ttl('username'))
    # print(redis_cli.get('username').decode())
    # redis_cli.set('username','杨锦', ex=120)
    # redis_cli.set('nusersex','1')
    # print(redis_cli.llen('list1'))
    # print('链接成功')
    redis_cli.hmset('studentname','stu1',)
else:
     print('失败')

